package com.neuedu.springmvc.controller;

import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 金山
 * 项目：springmvc-learn
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2025/3/1813:37
 */

@RestController
@RequestMapping("/dept")
public class DeptController {


    /**
     * http://127.0.0.1:8080/web/dept/get?id=10
     * http://127.0.0.1:8080/web/dept/get/10
     * @param id
     * @return
     */
    @RequestMapping("/get/{id}/{name}")
    public Map getById(@PathVariable  int id    ,@PathVariable String  name){

        System.out.println("id = " + id);
        System.out.println("根据id，查询数据库");
        Map map = new HashMap();
        map.put("deptno",1000);
        map.put("dname","研发部");

        return map;
    }


    @RequestMapping("/delete/{id}")
    public String delete(@PathVariable("id")  int deptNo   ){

        System.out.println("deptNo = " + deptNo);
        System.out.println("deptNo，删除操作");

        return "ok";
    }


    /**
     * http://127.0.0.1:8080/web/dept/
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public String  get(){
        return "get method invoke ";
    }


    /**
     * http://127.0.0.1:8080/web/dept/
     * @return
     */
    @RequestMapping(method = RequestMethod.POST)
    public String  post(){
        return "post method invoke ";
    }




    @DeleteMapping
    // @RequestMapping(method = RequestMethod.DELETE)
    public String  delete(){
        return "delete method invoke";
    }

    @PutMapping
    // @RequestMapping(method = RequestMethod.PUT)
    public String  put(){
        return "put invoke ";
    }

}
